package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AssesRuleSystem;
import com.ruoyi.system.domain.PointsRuleSystem;
import com.ruoyi.system.service.IAssesRuleSystemService;
import com.ruoyi.system.service.IPointsRuleSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统考核规则Controller
 *
 * @author ruoyi
 * @date 2024-04-22
 */
@RestController
@RequestMapping("/system/assesRule/system")
public class AssesRuleSystemController extends BaseController
{
    @Autowired
    private IAssesRuleSystemService assesRuleSystemService;

    /**
     * 查询系统考核规则列表
     */
    @PreAuthorize("@ss.hasPermi('system:system:list')")
    @PostMapping("/list")
    public AjaxResult list(@RequestBody AssesRuleSystem assesRuleSystem)
    {
        List<AssesRuleSystem> list = assesRuleSystemService.selectAssesRuleSystemList(assesRuleSystem);
        return success(list);
    }


//    /**
//     * 获取系统考核规则详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('system:system:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return success(pointsRuleSystemService.selectPointsRuleSystemById(id));
//    }

    /**
     * 新增系统考核规则
     */
    @PreAuthorize("@ss.hasPermi('system:system:add')")
    @Log(title = "系统考核规则", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody AssesRuleSystem assesRuleSystem)
    {
        return assesRuleSystemService.insertAssesRuleSystem(assesRuleSystem);
    }

    /**
     * 修改系统考核规则
     */
    @PreAuthorize("@ss.hasPermi('system:system:edit')")
    @Log(title = "系统考核规则", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody AssesRuleSystem assesRuleSystem)
    {
        return assesRuleSystemService.updateAssesRuleSystem(assesRuleSystem);
    }

    /**
     * 删除系统考核规则
     */
    @PreAuthorize("@ss.hasPermi('system:system:remove')")
    @Log(title = "系统考核规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(assesRuleSystemService.deleteAssesRuleSystemById(id));
    }
}
